<?php
	$hideLogin = true;
	include'top.php';

	if(array_key_exists("myusername",$_POST))
	{
		$myusername = $_POST['myusername'];
		$mypassword = $_POST['mypassword'];
		$mypassword2 = $_POST['mypassword2'];

		if($mypassword == $mypassword2)
		{
			$con = mysql_connect("localhost","root","$username","$password");
				if (!$con)
				{
					die('Could not connect: ' . mysql_error());
				}
		
			mysql_select_db("rgfusion", $con);

			$sql="SELECT * FROM users WHERE username='$myusername'";
			$result=mysql_query($sql);
			$count=mysql_num_rows($result);	

			if($count == 1)
			{
				echo "Get another one yo";
			}
			else
			{
				mysql_query("INSERT INTO users VALUE(NULL,'$myusername',PASSWORD('$mypassword'))");
				$sql="SELECT * FROM users WHERE username='$myusername'";
				$result=mysql_query($sql);
				$row=mysql_fetch_array($result);
				setcookie("user",$row["Id"] . "," . $row["Password"]);
				header("location:Homepage.php");
			}
		}
		else
		{
			echo "It don't match nagger!";
		}
	}
?>

		<form name="form2" method="post" action="Register.php">
			<label for="myusername">Enter a username </label>
			<input name="myusername" type="text" id="myusername" />
			<label for="mypassword">Enter a Password </label>
			<input name="mypassword" type="password" id="mypassword" />
			<label for="mypassword">Enter password again </label>
			<input name="mypassword2" type="password" id="mypassword2" />
			<input name="Submit" type="submit" value="Register">
		</form>
	</body>
</html>
